package com.shxzz.easy12306.services.pay.controller;

import com.shxzz.easy12306.framework.starter.convention.result.Result;
import com.shxzz.easy12306.framework.starter.convention.result.Results;
import com.shxzz.easy12306.services.pay.dto.base.PayRequest;
import com.shxzz.easy12306.services.pay.dto.convert.PayCommandConvert;
import com.shxzz.easy12306.services.pay.dto.req.PayCommand;
import com.shxzz.easy12306.services.pay.dto.resp.PayResponse;
import com.shxzz.easy12306.services.pay.service.PayService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 支付控制层
 * @author shxzz
 * @create 2024-03-11-21:29
 */
@RequiredArgsConstructor
@RestController
public class PayController {

    private final PayService payService;

    /**
     * 公共支付接口
     */
    @PostMapping("/api/pay-service/pay/create")
    public Result<PayResponse> pay(@RequestBody PayCommand requestParam) {
        PayRequest payRequest = PayCommandConvert.convert(requestParam);
        return Results.success(payService.commonPay(payRequest));
    }

}
